{
  // 导航栏
  const navElements = document.getElementsByTagName("nav");
  const navClick = (e) => {
    /** @type { HTMLElement } */
    const nav = e.target;
    nav.opened = !nav.opened;
    nav.classList.toggle("close");
    nav.classList.toggle("open");

    if (!e.target.classList.contains("nav") && e.target.tagName !== "NAV") {
      return;
    }

    if (nav.opened) {
      document.body.style.overflow = "hidden";
    } else {
      document.body.style.overflow = "auto";
    }
  };
  for (let index = 0; index < navElements.length; index++) {
    const element = navElements[index];

    element.opened = false;
    element.classList.add("close");
    window.addEventListener("resize", (e) => {
      element.classList.remove("open");
    });
    element.addEventListener("click", navClick);
    element.addEventListener("touched", navClick);
    element.addEventListener("animationend", (e) => {
      /** @type { HTMLElement } */
      const nav = e.target;
      nav.style.animation = "";
    });
  }
}
